<!doctype html>
<html lang="zh">

<head>
   <meta charset="UTF-8">
    <title>添加设备类型</title>
    <link rel="stylesheet" href="./asset/css/components.css" />
    <link rel="stylesheet" href="./asset/css/bootstrap.css" />
    <link rel="stylesheet" href="./asset/css/plugins.css" />
    <link rel="stylesheet" href="./asset/css/main.css" />
    <link rel="stylesheet" href="./asset/css/themes.css" />
</head>

<body>
    <div id="body">
        <div id="app">
            <div class="tabbody">
                <div class="bodyli active">
                    <div class="inputbox">
                        <span class="title">类型名称</span>
                        <div class="inputright">
                            <input type="text" id="catename" v-model="catename" class="form-control input-sm" placeholder="请输入类型名称">
                        </div>
                    </div>
                    <div class="inputbox">
                        <span class="title">备注</span>
                        <div class="inputright">
                            <input type="text" id="memo" v-model="memo" class="form-control input-sm" placeholder="请输入备注">
                        </div>
                    </div>
            <div class="tbfooter">
                <button class="btn btn-success" @click.prevent="save()"><i class="fa fa-floppy-o"></i> 提交保存</button>
                &nbsp;&nbsp;&nbsp;
                <button class="btn btn-default" @click.prevent="reset()"><i class="fa fa-recycle"></i> 取消重置</button>
            </div>
        </div>
    </div>

    <script type="text/javascript" src="./asset/js/jquery.min.js"></script>
    <script type="text/javascript" src="./asset/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="./asset/js/axios.min.js"></script>
    <script type="text/javascript" src="./asset/js/vue.js"></script>
	  <script type="text/javascript">
		const vue = new Vue({ // 实例化Vue对象
			el: '#app',// 绑定作用域
			data: { //定义数据
				catename: '', // 定义类型名称数据
				memo: '', // 定义备注数据
			},
			methods: {
				save: function () {
					let _this = this;
					var data = {
						catename: _this.catename,
						memo: _this.memo,
					};
					axios.post('http://127.0.0.1:8080/equipment/cate/insertCate.action', data).then(result => {
						if (result.data.code > 0) {
							if (window.confirm('保存成功,是否继续添加？')) {
								_this.reset();
							} else {
								var index = parent.layer.getFrameIndex(window.name);
								parent.location.reload();
								parent.layer.close(index);
							}
						} else {
							console.log('保存失败,请稍后再试');
						}
					});
				},
				reset: function () {
					this.pageLoad();
				},
				pageLoad: function () { // 页面加载
					this.catename= '';
					this.memo= '';
				},
				validate: function () { // 验证输入非空
				},
			},
			created() { // 生命周期相关的函数
				let _this = this;
				_this.pageLoad();
			},
		})
	</script>

</body>

</html>


